﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;

namespace NuaTarDoneng.Tail
{
    /// <summary>
    /// Log 的摘要说明
    /// </summary>
    public class Log : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            string result = "";
            context.Response.ContentType = "text/plain";
            if ("527160681lier171" == context.Request.QueryString["key"])
            {
                if ("clean" == context.Request.QueryString["action"])
                {
                    Logs.Cleans(context);
                    result = "Log被清除";
                }
                else
                {
                    result ="日志内容如下：\r\n"+ File.ReadAllText(context.Server.MapPath("/Tail/Log.txt"));
                    
                }
            }
            else
            {
                result = "Hello Pig!!!";
            }
            context.Response.Write(result);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}